<?php
class Ward extends Eloquent
{
    public static $timestamps = false;

    public function district()
    {
        return $this->belongs_to('District');
    }

    public function anchors ()
    {
        return $this->has_many('Anchor');
    }

    public static function all_by_district($district_id)
    {
        return static::where_district_id($district_id)->get();
    }

    public static function all_by_city($city_id)
    {
        $districts = District::all_by_city($city_id);
        $wards = array();
        foreach ($districts as $d) {
            $wards = array_merge($wards, static::all_by_district($d->id));
        }

        return $wards;
    }

}